package cn.juque.jdfsystem.inits;

import cn.juque.jdfsystem.cache.BlacklistInfoCache;
import cn.juque.jdfsystem.cache.ConfigInfoCache;
import cn.juque.jdfsystem.cache.PlatformInfoCache;
import cn.juque.jdfsystem.service.IConfigInfoService;
import cn.juque.jdfsystem.service.IRegisterInfoService;
import cn.juque.jdfsystem.service.IUserInfoService;
import cn.juque.jdfsystem.threads.JdfThreadPoolFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author juque
 * @version 1.0.0
 * <ul>
 *     <li>JdfSystemInitRunner</li>
 * </ul>
 * @date 2023-01-10 23:57:13
 **/
@Slf4j
@Component
public class JdfSystemInitRunner implements ApplicationRunner {

    @Resource
    private IConfigInfoService configInfoService;

    @Resource
    private IUserInfoService userInfoService;

    @Resource
    private IRegisterInfoService registerInfoService;

    @Resource
    private ConfigInfoCache configInfoCache;

    @Resource
    private PlatformInfoCache platformInfoCache;

    @Resource
    private BlacklistInfoCache blacklistInfoCache;

    @Resource
    private JdfThreadPoolFactory jdfThreadPoolFactory;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        this.configInfoService.init();
        this.configInfoCache.refresh();
        this.registerInfoService.init();
        this.userInfoService.init();
        this.platformInfoCache.refresh();
        this.jdfThreadPoolFactory.init();
        this.blacklistInfoCache.refresh();
    }
}
